﻿using LogManager.Core.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace LogManager.Core.Services.Location
{
    public class LogFilesSearchResult : SimpleServiceResult
    {
        public ReadOnlyCollection<LogFile> Files { get; private set; }

        private LogFilesSearchResult(IList<LogFile> files, bool succeeded, string message) :
            base(succeeded, message)
        {
            this.Files = new ReadOnlyCollection<LogFile>(files);
        }

        public static LogFilesSearchResult CreateSuccess(IList<LogFile> files, string message)
        {
            return new LogFilesSearchResult(files, true, message);
        }

        public static new LogFilesSearchResult CreateFailure(string message, Exception error)
        {
            var instance = new LogFilesSearchResult(Enumerable.Empty<LogFile>().ToList(), false, message);
            instance.Error = error;
            return instance;
        }
    }
}
